const http = require('http');

const url = require('url');

const server = http.createServer((request,response) => {
    //获得访问的路径
    // console.log(request.url)//非常的不好解析
    // const obj = url.parse(request.url);//解析路径和查询字符串
    const obj = url.parse(request.url,true);//将查询字符串变成一个对象 后面加true
    // console.log(obj);
    //路径
    let path = obj.pathname;
    console.log(path);
    //查询字符串
    let query = obj.query;
    console.log(query);
    //获得查询字符串的值
    console.log(query.keyword);
    response.end('url');
});

server.listen(9000,() => {
    console.log("服务已经启动 9000端口开始监听....");
});